#ifndef COMMONPAGE_H
#define COMMONPAGE_H

#include <QWidget>
#include "musiclist.h"
#include <QMediaPlaylist>

enum PageType
{
    LIKE_PAGE, // 我喜欢⻚⾯
    LOCAL_PAGE, // 本地下载⻚⾯
    HISTORY_PAGE // 最近播放⻚⾯
};


namespace Ui {
class CommonPage;
}

class CommonPage : public QWidget
{
    Q_OBJECT

public:
    explicit CommonPage(QWidget *parent = nullptr);
    ~CommonPage();
    void setCommonPageUI(const QString &title, const QString &image);
    void setMusicListType(PageType pageType);
    void reFresh(MusicList& musicList);
    void addMusicToPlayer(MusicList &musicList, QMediaPlaylist *playList);
    const QString& getMusicIdByIndex(int index) const;
    void setImageLabel(QPixmap pixMap);
private:
    void addMusicToMusicPage(MusicList &musicList);
signals:
    void updateLikeMusic(bool isLike, QString musicId);
    void playAll(PageType pageType);
    void playMusicByIndex(CommonPage*, int);
private:
    Ui::CommonPage *ui;
    QVector<QString> musicListOfPage;
    PageType pageType;
};

#endif // COMMONPAGE_H
